package com.cl.blog.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @TableName b_content
 */
@TableName(value = "b_content")
@Data
public class BContent implements Serializable {
	/**
	 *
	 */
	@TableId(type = IdType.AUTO)
	private Integer id;

	/**
	 * 创建id
	 */
	private LocalDateTime createTime;

	/**
	 * 获得的点赞数量
	 */
	@TableField(value = "`like`")
	private Long like;

	/**
	 * 发布者id
	 */
	private Integer userId;

	/**
	 * 收藏数量
	 */
	private Long collect;

	/**
	 * 当前状态0（草稿），1（审核中），2（已发布）
	 */
	@TableField(value = "`status`")
	private Integer status;

	/**
	 * 是否删除
	 */
	private Integer isDelete;

	/**
	 * 文章内容
	 */
	private String content;

	/**
	 * 分类id
	 */
	private Integer typeId;
	/**
	 * 文章附属id，主要用来存储前检索
	 */
	private String contentId;

	/**
	 * 标签
	 */
	private String tagsId;

	/**
	 *
	 */
	private LocalDateTime updateTime;

	/**
	 *
	 */
	private String title;

	/**
	 * 文章描述
	 */
	private String description;

	/**
	 * 文章首图
	 */
	private String firstPicture;

	/**
	 * 是否开启评论
	 */
	private Integer isReview;

	/**
	 * 文章类型0（原创），1（转载），2（翻译）
	 */
	private Integer model;

	/**
	 * 历史观看人数
	 */
	private Long historyPeopleCount;


	@TableField(exist = false)
	private static final long serialVersionUID = 1L;

	@TableField(exist = false)
	private String typeName;

	@TableField(exist = false)
	private List<BTag> tags;

	@TableField(exist = false)
	private String author;


	@Override
	public boolean equals(Object that) {
		if (this == that) {
			return true;
		}
		if (that == null) {
			return false;
		}
		if (getClass() != that.getClass()) {
			return false;
		}
		BContent other = (BContent) that;
		return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
				&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
				&& (this.getLike() == null ? other.getLike() == null : this.getLike().equals(other.getLike()))
				&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
				&& (this.getCollect() == null ? other.getCollect() == null : this.getCollect().equals(other.getCollect()))
				&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
				&& (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete()))
				&& (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
				&& (this.getTypeId() == null ? other.getTypeId() == null : this.getTypeId().equals(other.getTypeId()))
				&& (this.getTagsId() == null ? other.getTagsId() == null : this.getTagsId().equals(other.getTagsId()))
				&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
				&& (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
				&& (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
				&& (this.getFirstPicture() == null ? other.getFirstPicture() == null : this.getFirstPicture().equals(other.getFirstPicture()))
				&& (this.getIsReview() == null ? other.getIsReview() == null : this.getIsReview().equals(other.getIsReview()))
				&& (this.getModel() == null ? other.getModel() == null : this.getModel().equals(other.getModel()))
				&& (this.getHistoryPeopleCount() == null ? other.getHistoryPeopleCount() == null : this.getHistoryPeopleCount().equals(other.getHistoryPeopleCount()));
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
		result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
		result = prime * result + ((getLike() == null) ? 0 : getLike().hashCode());
		result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
		result = prime * result + ((getCollect() == null) ? 0 : getCollect().hashCode());
		result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
		result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
		result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
		result = prime * result + ((getTypeId() == null) ? 0 : getTypeId().hashCode());
		result = prime * result + ((getTagsId() == null) ? 0 : getTagsId().hashCode());
		result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
		result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
		result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
		result = prime * result + ((getFirstPicture() == null) ? 0 : getFirstPicture().hashCode());
		result = prime * result + ((getIsReview() == null) ? 0 : getIsReview().hashCode());
		result = prime * result + ((getModel() == null) ? 0 : getModel().hashCode());
		result = prime * result + ((getHistoryPeopleCount() == null) ? 0 : getHistoryPeopleCount().hashCode());
		return result;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(getClass().getSimpleName());
		sb.append(" [");
		sb.append("Hash = ").append(hashCode());
		sb.append(", id=").append(id);
		sb.append(", createTime=").append(createTime);
		sb.append(", like=").append(like);
		sb.append(", userId=").append(userId);
		sb.append(", collect=").append(collect);
		sb.append(", status=").append(status);
		sb.append(", isDelete=").append(isDelete);
		sb.append(", content=").append(content);
		sb.append(", typeId=").append(typeId);
		sb.append(", tagsId=").append(tagsId);
		sb.append(", updateTime=").append(updateTime);
		sb.append(", title=").append(title);
		sb.append(", description=").append(description);
		sb.append(", firstPicture=").append(firstPicture);
		sb.append(", isReview=").append(isReview);
		sb.append(", model=").append(model);
		sb.append(", historyPeopleCount=").append(historyPeopleCount);
		sb.append(", serialVersionUID=").append(serialVersionUID);
		sb.append("]");
		return sb.toString();
	}
}